package com.hsmpay.mobile.service.zytl;

import com.hsmpay.common.pojo.qian4.Qian4SendLog;
import com.hsmpay.common.util.jiami.Des3;
import com.hsmpay.mobile.action.account.qian48.Q4BaseAction;

public class ZYTLParamService {

    /**
     * 加密中亿交易参数
     * @param param
     * @return
     */
    public static Qian4SendLog jiami(Qian4SendLog param) throws Exception {
        //解密pin秘钥和track秘钥
        String pinKeyD = Des3.decode3DES(Q4BaseAction.pinKey, Q4BaseAction.masterKey);
        String trackKeyD = Des3.decode3DES(Q4BaseAction.trackKey, Q4BaseAction.masterKey);
        //拿解密出来的明文pin秘钥和track秘钥加密pin,track2
        param.setPin(Des3.encryptPin(param.getAccountNumber(), param.getPin(), pinKeyD));
        param.setTrack2Data(Des3.encryptStanderTranck(trackKeyD, param.getTrack2Data()));
        Long roleId = param.getRoleId();
        if(roleId == 2){
            param.setTerminalId(Q4BaseAction.TERMINAL_ID_FL);
        }else if(roleId == 3){
            param.setTerminalId(Q4BaseAction.TERMINAL_ID_FD);
        }
        return param;
    }

}
